package com.tz.hotelmanager.controller;

import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tz.hotelmanager.mapper.impl.FloorMapperImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tz.hotelmanager.Utils.*;
import com.tz.hotelmanager.domain.Floor;
import com.tz.hotelmanager.domain.FloorExample;

@RestController()
@RequestMapping("/floor/")
public class FloorController {

  @Autowired
  FloorMapperImpl floorMapperImpl;

  @PostMapping(value="getFloor")
  public String getFloor(@RequestBody JSONObject jsonparm, HttpServletRequest request, HttpSession session) {
      //TODO: process POST request
      JSONObject result =new JSONObject();
      FloorExample floorExample = new FloorExample();
      List<Floor> floors = floorMapperImpl.selectByExample(floorExample);
      JSONArray jsonArray = new JSONArray();
      for (Floor floor : floors) {
        jsonArray.add(JSONObject.parse(floor.toString()));
      }
      result.put("data", jsonArray);
      return result.toJSONString();
  }
  @PostMapping(value="addFloor")
  public String addFloor(@RequestBody JSONObject jsonparm, HttpServletRequest request, HttpSession session) {
      //TODO: process POST request
      JSONObject result =new JSONObject();
      result.put("DSDS", 123);
      return result.toJSONString();
  }
  @PostMapping(value="delFloor")
  public String delFloor(@RequestBody JSONObject jsonparm, HttpServletRequest request, HttpSession session) {
      //TODO: process POST request
      JSONObject result =new JSONObject();
      result.put("DSDS", 123);
      return result.toJSONString();
  }
  @PostMapping(value="updateFloor")
  public String updateFloor(@RequestBody JSONObject jsonparm, HttpServletRequest request, HttpSession session) {
      //TODO: process POST request
      JSONObject result =new JSONObject();
      result.put("DSDS", 123);
      return result.toJSONString();
  }
}